[SUBROUTINE]
version = 1.14
icon = lathe-surface.png
name = _("Turning")
type = turning
help = _("<b>External straight turning with optional radiuses</b>&#10;Uses compensation with a radius&#10;Cutter orientation should be 1, 2, 9 or None")
order = act hx b_x e_x hz b_z e_z h2 ropt r hf fin

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_HX]
name = _("X axis")
type = sub-header

[PARAM_B_X]
name = _("Begin diameter")
type = float
icon = x.png
value = 1.0
metric_value = 25.0
minimum_value = 0.0
not_allowed = 0
header = hx

[PARAM_E_X]
name = _("End diameter")
type = float
icon = x-end.png
value = 0.8
metric_value = 20.0
minimum_value = 0.0
header = hx

[PARAM_HZ]
name = _("Z axis")
type = sub-header

[PARAM_B_Z]
name = _("Begin")
type = float
icon = z.png
value = 0.0
metric_value = 0.0
header = hz

[PARAM_E_Z]
name = _("End")
type = float
icon = z-end.png
value = -1.0
metric_value = -25.0
header = hz

[PARAM_H2]
name = _("Options")
type = sub-header

[PARAM_ROPT]
name = _("End radius")
type = combo
options = _("None w/ compensation=0:None w/o compensation=1:Full radius=2:Stop at Begin diameter=3")
value = 1
;tool_tip = _("Less than cutter radius means no radius at end")
;icon = inner-radius.png
header = h2
value_changed =
	parent.get_param('param_r').set_grayed(new_val < '2')

[PARAM_R]
name = _("Radius")
type = float
value = 0.0
metric_value = 0.0
minimum_value = 0.0
tool_tip = _("Less than cutter radius means no radius at end")
icon = inner-radius.png
header = h2
grayed = 1

[PARAM_HF]
name = _("Finishing")
type = sub-header

[PARAM_FIN]
name = _("Number of passes")
icon = finish.png
type = int
value = 1
minimum_value = 0
tool_tip = _("Or spring passes")
header = hf

[INIT]
content =
	a = parent.get_param('param_ropt').get_attr('value')
	parent.get_param('param_r').set_grayed(a < '2')

[VALIDATION]
content =
	if #param_act == 1 :
		if self.check_hash('#param_b_x', 0.6) < self.check_hash('#param_e_x', 0.5) :
			self.msg_inv(_('Begin diameter must be greater than End diameter'), 1)
			VALIDATED = False
	
		bz = self.check_hash('#param_b_z', 0.0)
		ez = self.check_hash('#param_e_z', 0.0)
		if (bz > ez) and TOOL_TABLE.get_tool_orient() not in [0, 2, 9] :
			self.msg_inv(_('Cutter orientation should be 2, 9 or 0'), 3)
		elif (bz < ez) and TOOL_TABLE.get_tool_orient() not in [0, 1, 9] :
			self.msg_inv(_('Cutter orientation should be 1, 9 or 0'), 3)

[CALL]
content =
	(begin #sub_name)
	(author : Fernand Veilleux)
	
	o<#self_id_act> if [#param_act]
		o<turning> CALL [#param_b_x] [#param_e_x] [#param_b_z] [#param_e_z] [#param_fin] [#param_r] [#param_ropt]
	o<#self_id_act> endif
	
	(end #sub_name)
